
let sql_list = []

sql_list.push(`
                select
    a.c_zyh as 住院号,
    b.管床医生 ,
    a.c_name as 姓名,
    c.c_sex_desc as 性别,
    c.c_age_str as 年龄,
    case when a.c_bed like '%床' then a.c_bed else concat(substring(a.c_bed,2,2),'床') end as 床号,
    c.c_ry_zd as 诊断,
    a.kyye as '住院费用',
    case datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d'))
    when 0 then '新入'
    when 1 then '昨入'
    else  datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d')) end as 天数  
    from patient_zyhs a
    left join  assistant_doctor b
    on a.c_zyh = b.住院号
    left join patient_details c
    on a.c_zyh = c.c_zyh
    where a.c_out_date is null
    order by 床号; 
    `)

sql_list.push(`
    select 
    a.c_code '1',
    a.c_name '2',
    c.性别 '3',
    a.c_age_desc '4',
    ifnull(e.c_addr_d,e.c_address) '5',
    c.门诊诊断 '6',
    concat('20',mid(a.c_code,1,2),'-',mid(a.c_code,3,2),'-',mid(a.c_code,5,2)) '7',
    d.d_name '8'
    from mz_p_code a
    left join mz_p_cost2 b on a.c_code=b.c_code 
    left join mz_p_jzxx c on a.c_code=c.就诊号
    left join doctor_id d on a.c_doctor_id=d.doctor_id
    left join mz_p_jbxx e on a.c_code=e.c_code 
    order by a.c_code desc limit 100
    `)

sql_list.push(`
    select
    a.c_zyh as 住院号,
    b.管床医生 ,
    a.c_name as 姓名,
    c.c_sex_desc as 性别,
    c.c_age_str as 年龄,
    case when a.c_bed like '%床' then a.c_bed else concat(substring(a.c_bed,2,2),'床') end as 床号,
    c.c_ry_zd as 诊断,
    a.kyye as '住院费用',
    case datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d'))
    when 0 then '新入'
    when 1 then '昨入'
    else  datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d')) end as 天数  
    from patient_zyhs a
    left join  assistant_doctor b
    on a.c_zyh = b.住院号
    left join patient_details c
    on a.c_zyh = c.c_zyh
    where a.c_out_date is null
    order by 床号;    
    `)

// 住院病程
sql_list.push(`
    select
    code,
    case when a.c_bed like '%床' then c_bed else concat(substring(c_bed,2,2),'床') end as 床号,
    a.c_zyh 住院号,
    a.c_name 姓名,
    e.c_sex_desc 性别,
    e.c_age_str 年龄,
    e.c_ry_zd 入院诊断,
    case when datediff(now(),f.c_ss_date)=0 then '今天' else datediff(now(),f.c_ss_date) end as  手术天数,
    case datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d'))
            when 0 then '新入'
            when 1 then '昨入'
            else  datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d')) end as 天数,
            case
    when g.c_ss_date is null then  '*'
    when datediff(now(),g.c_ss_date)=0 then  'ok' 
    when datediff(now(),g.c_ss_date)=1 then  '后'
    when datediff(now(),g.c_ss_date)=2 then  '明'
    when datediff(now(),g.c_ss_date)>2  then  '✓'   end as 治疗,
    case when e.c_dw_name is null then e.c_nowaddr_d else  e.c_dw_name end as 地址,
    case when e.c_tel is null then e.c_lx_tel else  e.c_tel end as 电话,
    a.c_wj_cost 费用
    from patient_zyhs a
    right join patient_self b on a.c_zyh = b.c_zyh
    left join assistant_doctor c on c.住院号 = b.c_zyh
    left join employee d on c.管床医生=d.name
    left join patient_details e on a.c_zyh = e.c_zyh
    left join operation f on a.c_zyh = f.c_zyh
    left join p_zl g on a.c_zyh = g.c_zyh
    where  a.c_out_date is null  and a.c_zyh is not null
    order by 床号
    `)


// 住院病程简
sql_list.push(`
    select
    a.c_zyh 住院号,
    case when a.c_bed like '%床' then c_bed else concat(substring(c_bed,2,2),'床') end as 床号,
    a.c_name 姓名,
    e.c_sex_desc 性别,
    e.c_age_str 年龄,
    e.c_ry_zd 入院诊断,
    case datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d'))
            when 0 then '新入'
            when 1 then '昨入'
            else  datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d')) end as 天数,
    case when e.c_dw_name is null then e.c_nowaddr_d else  e.c_dw_name end as 地址
    from patient_zyhs a
    right join patient_self b on a.c_zyh = b.c_zyh
    left join assistant_doctor c on c.住院号 = b.c_zyh
    left join employee d on c.管床医生=d.name
    left join patient_details e on a.c_zyh = e.c_zyh
    left join operation f on a.c_zyh = f.c_zyh
    left join p_zl g on a.c_zyh = g.c_zyh
    where  a.c_out_date is null  and a.c_zyh is not null
    order by 床号
    `)

sql_list.push(`
    select
    a.c_zyh as 住院号,
    a.c_name as 姓名,
    c.c_sex_desc as 性别,
    c.c_age_str as 年龄,
    case when a.c_bed like '%床' then a.c_bed else concat(substring(a.c_bed,2,2),'床') end as 床号,
    c.c_ry_zd as 诊断,
    a.kyye as '住院费用',
    case datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d'))
    when 0 then '新入'
    when 1 then '昨入'
    else  datediff(now(),date_format(a.c_ry_date,'%Y-%m-%d')) end as 天数  
    from patient_zyhs a
    left join  assistant_doctor b
    on a.c_zyh = b.住院号
    left join patient_details c
    on a.c_zyh = c.c_zyh
    where a.c_out_date is null
    order by 床号;    
    `)